home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / DOSTIPS6.ZIP / DOSDISK < prev    next >
Text File  |  1987-03-03  |  13KB  |  226 lines

  1.                       Why It Doesn't Add Up
  2.         (PC Magazine Vol 6 No 6 March 31, 1987 PC Tutor)
  3.  
  4.      A curious thing occurs with hard disks, their capacity and the
  5. amount of space used by files.  For example, you might run CHKDSK on
  6. a 20-meg hard disk and it shows about 21 megabytes of disk space.  You
  7. might have something like 12 megabytes in 770 files and 9 megabytes
  8. free.  But when you add up the sizes of all the files manually, you
  9. could account for only something like 8 megabytes leaving some 4
  10. megabytes unaccounted for.  Using a hard disk is like going shopping
  11. with only dollar bills and never getting any change back.
  12.      The entire data area of a hard disk is divided into smaller areas
  13. called clusters.  Files on a disk are always stored in one or more
  14. clusters.  If the file does not fill up the last cluster it occupies,
  15. then the rest of the space in that cluster is lost.  The number of
  16. byte in each file reported by the DIR command is the size of the file
  17. when it was created or last modified.  The amount of space that file
  18. actually requires on the disk is the size of the file after rounding
  19. up to the next multiple of the cluster size.
  20.      You can easily determine the cluster size of a particular disk.
  21. First, do a DIR and note the "bytes free" value.  Then create a very
  22. small file.  The easiest method is by issuing the command:
  23.  
  24. ECHO > SMALLFIL
  25.  
  26. Now do another DIR and see how much space you've lost.  That's your
  27. cluster size.
  28.      Cluster size is always a power of 2, and for most normal disks it
  29. is a multiple of 512.  Some RAMdisks may have cluster sizes of 128 or
  30. 256, but real disks have cluster sizes of 512, 1024, 2048, 4096, and
  31. 8192 bytes.  For a single-sided floppy diskette, the cluster size is
  32. 512 bytes.  For a double-sided diskette, it's 1024 bytes.  For a 10-
  33. megabyte hard disk, the cluster size is 4096 bytes.
  34.      For hard disks larger than 10 megabytes, the cluster size is
  35. dependent upon the DOS version used when the disk was originally
  36. configured with FDISK and FORMAT.  A 20-megabyte hard disk originally
  37. configured under DOS 2.x has a cluster size of 8192 bytes.
  38.      On average, you will probably lose about half a cluster for each
  39. file on the disk.  For the 770 files in the above example, this alone
  40. accounts for about 3 megabytes.  If you have a lot of small files whose
  41. length is less than half a cluster in size, this will account for more
  42. loss.  In this connection, note that subdirectories (the actual names
  43. of the subdirectories, not the files in them) are stored in the data
  44. area and are subject to the same rules that govern the space required
  45. for data files.  CHKDSK reports those figures also.
  46.      The real culprit here is the 8192-byte cluster size.  It sounds
  47. too big for most uses, and it is.  It is the direct result of the
  48. method of storing files on a disk that was introduced way back in
  49. DOS 1.0.  This method limited the total number of clusters on a disk
  50. to 4078 (which is 4096 minus some cluster numbers used for special
  51. purposes).
  52.      Under DOS 3.0 and later, however, the total number of possible
  53. clusters on a hard disk was increased to 65,518.  This allows using a
  54. much smaller cluster size for a hard disk.  A 20- or 30-megabyte hard
  55. disk that has been FDISKed and formatted under DOS 3.x has a cluster
  56. size of 2048 bytes.  That's more reasonable.
  57.      (With 65,518 clusters available, it is theoretically possible to
  58. have a cluster size of 512 bytes for a 20- or 30-megabyte disk, but
  59. you really don't want clusters that small.  Since files may be stored
  60. in noncontiguous areas of a disk, a very small cluster size would
  61. result in files becoming highly fragmented, which would have the effect
  62. of slowing down file access time.)
  63.      It is interesting to note that prior to DOS 3.0 (which was
  64. introduced at the same time as the IBM PC AT), IBM did not sell a hard
  65. disk over 10 megabytes.  The original PC AT had IBM's first 20-megabyte
  66. hard disk.  Although it is entirely possible to install a 20- or 30-
  67. megabyte drive on a PC or XT running DOS 2.x, nobody working with
  68. strict IBM parts ever actually had a cluster size over 4096 bytes.
  69. The problem of excessively large cluster sizes was thus fixed when
  70. IBM simultaneously introduced a 20-megabyte hard disk and DOS 3.  In
  71. a sense, then, it's not even IBM's problem if you have a 8192-byte
  72. cluster size.
  73.      If you have a hard disk over 10 megabytes originally configured
  74. under DOS 2.x, you can usually reconfigure it under DOS 3.x to get a
  75. smaller cluster size.  Read through this section and think about it
  76. before you begin.  It's a big job and it's scary.  If you don't feel
  77. comfortable with it and you're not sure if you can adequately handle
  78. any problems, don't do it.
  79.      This procedure assumes that your hard disk is connected to a hard
  80. disk controller card that has its own ROM BIOS, that you don't need
  81. anything special in a CONFIG.SYS file to use the hard disk, and that
  82. you (or somebody at your computer store) originally configured the
  83. hard disk by running the normal FDISK and FORMAT commands included in
  84. IBM's PC-DOS 2.x.
  85.      You'll need a version of PC-DOS 3.0 or later for this.  The most
  86. recent DOS version is 3.2.
  87.      First, you must back up your entire hard disk, using BACKUP.  Do
  88. it twice to play it safe.  For 12 megabytes of files, you'll need six
  89. or seven boxes of ten diskettes for the two backups.  Use high-quality
  90. diskettes for this.  Format them all before you begin.  Don't use any
  91. that have bad sectors.  The BACKUP command you want is:
  92.  
  93. BACKUP C:\*.* A: /S
  94.  
  95. This backs up everything on drive C:, including all subdirectories.
  96. BACKUP will prompt you to put in new diskettes.  Label them in sequence
  97. as you go, as you will have to RESTORE them later in the same order.
  98.      When you're done with the backup, boot up PC-DOS 3.2 from drive
  99. A: and enter:
  100.  
  101. FDISK
  102.  
  103. Once in the FDISK program, you must first delete the existing DOS
  104. partition, which is one of the options on the menu.  Then you must
  105. create a DOS partition, which is another option on the menu.  You
  106. probably want to use teh entire hard disk for DOS, so answer Yes to
  107. that question.  Your system will not reboot.  Make sure the DOS 3.2
  108. diskette is still in drive A:.
  109.      When you get back to the DOS prompt, you format the hard disk:
  110.  
  111. FORMAT C:/S/V
  112.  
  113. (The /V is optional but allows you to give your hard disk a volume
  114. label, otherwise known as a name.)  After this is done, you can verify
  115. that everything is running smoothly by doing a DIR and a CHKDSK on
  116. drive C:.  Try rebooting with the drive A: door open.  Your machine
  117. should boot from the hard disk.  A VER command should report DOS 3.2
  118. (the DOS version you are using).  At this point, you can create a small
  119. file to see if your cluster size is indeed smaller.  It should be 2048
  120. bytes.
  121.      Delete your small test file and boot up again from the DOS 3.2
  122. floppy.  Now you can proceed to RESTORE the backed-up files onto your
  123. hard disk.  You should use the DOS 3.2 RESTORE command with the syntax:
  124.  
  125. RESTORE A: C:\*.* /S /P
  126.  
  127.      This whole process can be very scary, and you may encounter some
  128. "gotchas" along the way.  First, some copy-protected programs installed
  129. on a hard disk may not work after a BACKUP and RESTORE.  Others will.
  130. Some of the problem programs (1-2-3 Release 2, for instance) can be
  131. deinstalled.  If you have any of these programs, deinstall them from
  132. the hard disk before you do your original backups and reinstall them
  133. when you're all done.  When in doubt, contact the manufacturer.  (After
  134. they give you the information you need, tell them what you think about
  135. copy protection.  Use whatever command syntax you feel appropriate.)
  136.      Second, people sometimes have problems with BACKUP and RESTORE.
  137. Sometimes RESTORE chokes in the middle of restoring from a bunck of
  138. diskettes.  That's why you should do two BACKUPs.  You may want to
  139. take other precautions.  Your hard disk probably has a number of
  140. purchased programs on it and a number of your own data files in various
  141. subdirectories.  You can probably re-create those purchased programs
  142. from the original diskettes.  For your own data files, particularly
  143. the ones most valuable to you, use the regular COPY command to copy
  144. them to diskettes.
  145.      Third, BACKUP will back up hidden and read-only files, including
  146. the DOS files called IBMBIO.COM and IBMDOS.COM.  When you run RESTORE,
  147. you want to use the /P switch as shown above, which prompts you when
  148. it is about to back-up over existing read-only files.  When you get
  149. the prompt for IBMBIO.COM and IBMDOS.COM, answer No.
  150.      Fourth, RESTORE will still copy the old version of COMMAND.COM
  151. from the backed-up floppies to your hard disk.  Thus, when you are
  152. done with the RESTORE operation, recopy COMMAND.COM from the DOS 3.2
  153. floppy diskette to the root directory of the hard disk, using:
  154.  
  155. COPY COMMAND.COM C:\
  156.  
  157. (If you boot from the newly formatted hard disk before running RESTORE,
  158. DOS will try to load the COMMAND.COM from the hard disk after RESTORE
  159. is completed.  But this would be the old COMMAND.COM.  This is why you
  160. should boot from the DOS 3.2 floppy before beginning RESTORE.  When
  161. RESTORE ends, you will be prompted to put the DOS disk in drive A:, so
  162. it can find the correct version of COMMAND.COM.)
  163.      Fifth, after you're done with the RESTORE, your hard disk will
  164. have regained copies of all the old-version DOS external programs,
  165. such as CHKDSK and MODE.  You must replace these with the new DOS 3
  166. versions.  DOS 3.2 has a command called REPLACE that automates this
  167. process.
  168.      Sixth, sometimes even after all this, funny things happen.  For
  169. instance, you may have trouble booting from drive C:.  If this is the
  170. case, boot from the DOS 3.2 floppy and get into FDISK again.  Choose
  171. the "Change the Active Partition" option in the menu.  If the status
  172. of the DOS partition is marked "N", it means it's nonactive, which
  173. explains why you can't boot from it.  Make it active.  Indeed,
  174. sometimes just entering and leaving FDISK fixes the problem by itself.
  175.      If you think that your hard disk still has the old DOS IBMBIO,
  176. IBMDOS, or COMMAND files on it, you can boot from the DOS 3.2 floppy
  177. and execute:
  178.  
  179. SYS C:
  180.  
  181. and
  182.  
  183. COPY COMMAND.COM C:\
  184.  
  185. This will reinstall DOS 3.2 on the hard disk.
  186.      Seventh, if you have a tape backup unit and you would rather use
  187. that instead of BACKUP and RESTORE, you should determine whether it
  188. does a file-by-file backup or an "image" backup.  Many tape backup
  189. units give you a choice.  You want to do a file-by-file backup.  If
  190. your tape backup unit can only do an image backup, don't use it.  The
  191. image stored on the tape will include the hard disk's file allocation
  192. table, and this will be a different format under DOS 3.x.  When you
  193. restore the hard disk from the imaged tape, the old file allocation
  194. table will be copied back to the disk.  No good.  If you do a file-by-
  195. file backup and restore, it will probably copy over the DOS files.
  196. Boto DOS 3.2 from drive A: and do the SYS command and COPY of
  197. COMMAND.COM before you try booting from the hard disk.
  198.      Eighth, after you've used DOS 3.x FDISK on a 20-megabyte or
  199. bigger disk, you cannot use the hard disk with any DOS version prior
  200. to 3.0.  If you subsequently try to boot up from a DOS 2.x floppy,
  201. DOS simply will not recognize the hard disk.  Some people (program
  202. developers, mainly) need to test programs under several DOS versions.
  203. These people may need to have their hard disks recognizable by DOS 2.x.
  204. They shouldn't reconfigure their hard disks, but should put up with the
  205. wastefully large 8192-byte cluster size instead.
  206.      Finally, this whole discussion is based on the IBM version of
  207. MS-DOS (which is called "Personal Computer DOS" by IBM and commonly
  208. called "PC-DOS" by the rest of us).  Some versions of MS-DOS for other
  209. manufacturers' machines may not support the smaller cluster size, so
  210. doing this will not have any effect.  Again, when in doubt, contact
  211. the manufacturer.
  212.      As an alternative to using the BACKUP/RESTORE procedure, you might
  213. wish to use the BAC.COM utility from PC Mag Vol 4 No 17.  It allows you
  214. to back up all the files in one (sub)directory at a time on the proper
  215. file-by-file (rather than image) basis, and it allows you to change
  216. diskettes as they become full.  This last reason is why you can't
  217. easily use the regular COPY command when backing up a whole hard disk.
  218. The files backed up onto floppies with BAC.COM (unlike those made using
  219. BACKUP) are immediately editable, so after backing up your hard disk
  220. files (two BAC copies are recommended for absolute safety) and before
  221. you FDISK and reformat your hard disk, you can delete the obsolete
  222. COMMAND.COM (and other old-version DOS external programs) from the
  223. backup floppies, saving some of the hassle when it comes time to put
  224. them back onto the newly formatted hard disk.
  225.  
  226.